// import Vue from 'vue'
import {
  fetchLookupList
} from '@/api/common'
import {
  getLookupItems,
  setLookupItems
} from '@/utils/auth'
const lookup = {
  state: {
    items: getLookupItems()
  },
  mutations: {
    SET_ITEMS: (state, items) => {
      state.items = items
      setLookupItems(items)
    }
  },
  actions: {
    GetLookupItems ({
      commit,
      state
    }) {
      return new Promise((resolve, reject) => {
        fetchLookupList().then(response => {
          const data = response
          if (Number(data.code) === 1) {
            // Vue.set(data.obj, 'ALLLANGUAGE', allLanguage)
            // 存储查找值
            commit('SET_ITEMS', data.obj)
          }
          resolve(data)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}
export default lookup
